﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.fminutes.vinciDll {
    import flash.events.*;
    import flash.net.*;

    public class IniToFlieList {

        public static var outFloder:String;

        private var floder:String;
        private var listCounter:int = 0;
        private var listLength:int;
        private var lang:String;
        private var loadComp:Function;
        private var status:String;
        private var mainFileList:FileList;
        private var _platformIniUrl:String;
        private var _platformOutUrl:String;

        public function analyzeXml(_arg1:Array, _arg2:String, _arg3:String, _arg4:Function, _arg5:String="", _arg6:String=""):void{
            this._platformIniUrl = _arg5;
            this._platformOutUrl = _arg6;
            this.mainFileList = new FileList();
            this.listLength = _arg1.length;
            this.lang = _arg2;
            this.status = _arg3;
            this.loadComp = _arg4;
            var _local7:int;
            while (_local7 < _arg1.length) {
                this.loadXml(_arg1[_local7]);
                _local7++;
            };
        }
        private function loadXml(_arg1:String):void{
            var _local2:URLLoader = new URLLoader(new URLRequest(_arg1));
            _local2.addEventListener(Event.COMPLETE, this.xmlComplete);
            _local2.addEventListener(IOErrorEvent.IO_ERROR, this.xmlError);
        }
        private function xmlComplete(_arg1:Event):void{
            var i:* = null;
            var dllFileObject:* = null;
            var e:* = _arg1;
            this.listCounter++;
            var xml:* = XML(e.target.data);
            if (this._platformIniUrl != ""){
                this.floder = this._platformIniUrl;
            } else {
                this.floder = xml.urlList.item.(@type == "folder").@url;
            };
            if (((!((this.floder == null))) && (!((this.floder == ""))))){
                Dll.getInstance().floder = this.floder;
            };
            if (this._platformOutUrl != ""){
                outFloder = this._platformOutUrl;
            } else {
                outFloder = xml.urlList.item.(@type == "outfolder").@url;
            };
            if (((!((outFloder == null))) && (!((outFloder == ""))))){
                Dll.getInstance().outFloder = outFloder;
            };
            var xmlList:* = xml.dllList.item;
            for (i in xmlList) {
                if ((((xmlList[i].@status == "all")) || ((xmlList[i].@status == this.status)))){
                    if ((((xmlList[i].@language == "all")) || ((xmlList[i].@language == Dll.getInstance().lang)))){
                        dllFileObject = new DllFileObject();
                        dllFileObject.name = xmlList[i].@name;
                        dllFileObject.groupName = xmlList[i].@groupName;
                        dllFileObject.type = xmlList[i].@type;
                        dllFileObject.size = xmlList[i].@size;
                        dllFileObject.weight = int(xmlList[i].@weight);
                        dllFileObject.module = xmlList[i].@module;
                        if (xmlList[i].@url != "main.swf"){
                            if (xml.urlList.item.@type == "folder"){
                                dllFileObject.url = (this.floder + xmlList[i].@url);
                            } else {
                                dllFileObject.url = (outFloder + xmlList[i].@url);
                            };
                        } else {
                            dllFileObject.url = xmlList[i].@url;
                        };
                        dllFileObject.serverid = (xmlList[i].@serverid) ? xmlList[i].@serverid : "0";
                        dllFileObject.status = DllFileObject.NOT_LOADED;
                        this.mainFileList.fileList.push(dllFileObject);
                    };
                };
            };
            if (this.listCounter == this.listLength){
                this.loadComp(this.mainFileList);
            };
        }
        private function xmlError(_arg1:IOErrorEvent):void{
            throw (new Error("加载配置XML文件出错"));
        }

    }
}//package com.fminutes.vinciDll 
